<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <meta http-equiv="Pragma" content="no-cache">
 <meta http-equiv="Cache-Control" content="no-cache">
 <meta http-equiv="Expires" content="Sat, 01 Dec 2001 00:00:00 GMT">
 <script language="javascript" type="text/javascript">
// <!CDATA[

function Button1_onclick() {
javascript:myForm.submit();
}



// ]]>
</script>
<title>Untitled Document</title>
</head>

<body>
<table width="100%" height="100%" border="2">
  <tr>
    <td width="22%" height="95"><img src="logo.png" width="163" height="154" alt="Logo" /></td>
    <td width="78%"><h1>Island Auctions</h1>
    <p> Turning Junk Into Money</p></td>
  </tr>
  <tr>
    <td valign="top"><p><a href="index.jsp">Home</a></p>
    <p><a href="Browse.jsp">Browse</a></p>
    <p><a href="Search.jsp">Search</a></p>
    <p><a href="profile.jsp">Profile</a></p>
    <p><a href="Users.jsp">Users</a></p>
    <%
    try{
	    if(session.getValue("login") != null)
	    {%>
	    	<p><a href="Logout.jsp">Logout</a></p>
	    <%}
	    else
	    {%>
	    	<p><a href="login.jsp">Login</a></p>
	    <%}
    }catch(java.lang.IllegalStateException e)
    {%>
		<p><a href="login.jsp">Login</a></p><%
}%>

<%
try{
    if(session.getValue("empLevel") == "1")
    {%>
    	<p><a href="ManageEmployees.jsp">(Manage Employees)</a></p></td>
    <%}
    else
    {%>
    <br>
    <%}
}catch(java.lang.IllegalStateException e)
{%>
<br>
<%}
    %>
    <td valign="top">

    <%
    if(session.getValue("login") == null)
    	response.sendRedirect("login.jsp");
    
    String mysJDBCDriver = "com.mysql.jdbc.Driver"; 
    String mysURL = "jdbc:mysql://mysql2.cs.stonybrook.edu:3306/jedale"; 
    String mysUserID = "jedale"; 
    String mysPassword = "107200855";

      			java.sql.Connection conn=null;
      			
    
    		try 
			{
    			int custID = (Integer)session.getValue("customerID");
    			
            	Class.forName(mysJDBCDriver).newInstance();
    			java.util.Properties sysprops=System.getProperties();
    			sysprops.put("user",mysUserID);
    			sysprops.put("password",mysPassword);
        
				//connect to the database
            	conn=java.sql.DriverManager.getConnection(mysURL,sysprops);
            	System.out.println("Connected successfully to database using JConnect");
    	        
				java.sql.ResultSet rs;
            	java.sql.Statement stmt1=conn.createStatement();
            	
            	rs = stmt1.executeQuery("Select ItemID From Item Order By ItemID DeSC");
            	rs.next();
            	int itemID = rs.getInt(1) + 1;
            	rs = stmt1.executeQuery("Select AuctionID From Auction Order By AuctionID DeSC");
            	rs.next();
            	int auctionID = rs.getInt(1) + 1;
            	
            	stmt1.close();
            	
            	
            	
            	
            	%>
            	<form name="myForm" action="makeAuction.jsp" method="post">
            	<input type="hidden" name="itemID" value="<%=itemID%>"></input>
            	<input type="hidden" name="auctionID" value="<%=auctionID%>">
            	<input type="hidden" name="userId" value="<%=custID%>">
            	
                    <span style="font-size: 10pt"><strong>Item Name:<br />
                    <input name="ItemName" style="font-weight: bold; font-size: 10pt; width: 145px" type="text" /><br />
                    
                                        <span style="font-size: 10pt"><strong>Item Description:<br />
                    <input name="ItemDescr" style="font-weight: bold; font-size: 10pt; width: 145px" type="text" /><br />
                    
                                        <span style="font-size: 10pt"><strong>Type:<br />
                    <input name="Type" style="font-weight: bold; font-size: 10pt; width: 145px" type="text" /><br />
                    
                                        <span style="font-size: 10pt"><strong>Number of Copies:<br />
                    <input name="Number" style="font-weight: bold; font-size: 10pt; width: 145px" type="text" /><br />
                    
                                        <span style="font-size: 10pt"><strong>Increment:<br />
                    <input name="Inc" style="font-weight: bold; font-size: 10pt; width: 145px" type="text" /><br />
                    
                                        <span style="font-size: 10pt"><strong>Starting Price:<br />
                    <input name="Starting" style="font-weight: bold; font-size: 10pt; width: 145px" type="text" /><br />
                    
                                        <span style="font-size: 10pt"><strong>Reserve:<br />
                    <input name="Reserve" style="font-weight: bold; font-size: 10pt; width: 145px" type="text" /><br />
                    
                                        <span style="font-size: 10pt"><strong>End Date:<br />
                    <input name="EndTime" style="font-weight: bold; font-size: 10pt; width: 145px" type="text" /><br />

                    
                    <input id="Button2" type="button" value="Finish"  onclick="return Button1_onclick()" />
                    &nbsp;
                    <input id="Button3" type="button" value="Cancel"  onclick="window.open('','_self');" /><br />
                </strong></span>
           </form>
            	<%
            	
  			} catch(Exception e)
			{
				e.printStackTrace();
				out.print(e.toString());
			}
			finally{
			
				try{conn.close();}catch(Exception ee){};
			}



%>





</td>
  </tr>
</table>
</body>
</html>